# -*- coding: utf-8 -*-

if __name__ == '__main__':
    import sys
    sys.path.insert(0, '../..')


__all__ = [
    'User', 'UserDevice',
    'Passport',
    'Session',
    'Device', 'DeviceSession', 'FieldAlias', 'DevicePackageRecord', 'DeviceAttribute',
    'Corp', 'CorpUser', 'CorpDevice',
    'ActionLog',
    'System',
    'Fact', 'Metric', 'CalculateMetric', 'Dimension', 'FactResource',
    'Rule', 'DeviceRule',
    'Warn',
    'Message', 'UserMessage',
    'Push',
    'Supply', 'SupplyPrint',
    'Sms', 'Information' , 'DemandPub', 'SuggestionBack',
    'ALiProduct','ProductAttribute',
    'TopicLog' ,'WarnContrast' ,'Telecontrol'
]

from base import BaseModel
from session import Session
from user import User, UserDevice
from passport import Passport
from device import Device, DeviceSession, FieldAlias, DevicePackageRecord, DeviceAttribute
from corp import Corp, CorpUser, CorpDevice
from action_log import ActionLog
from system import System
from rule import Rule, DeviceRule
from analytics import Fact, Metric, CalculateMetric, Dimension, FactResource
from warn import Warn,WarnContrast
from message import Message, UserMessage
from push import Push
from supply import Supply, SupplyPrint
from sms import Sms
from demand_pub import DemandPub, SuggestionBack
from news_info import Information
from aliyuniot import ALiProduct,ProductAttribute
from topic_history import TopicLog
from app_update import AppUpdate
from telecontrol import Telecontrol

def init_data():
    from sqlalchemy import create_engine
    from sqlalchemy.orm import sessionmaker
    Engine = create_engine('mysql://root@localhost:3306/core1', echo=True)

    Session = sessionmaker(Engine)
    session = Session()
    session.commit()
    session.close()


def init_db(engine):
    BaseModel.metadata.create_all(engine)
    init_data()


def drop_db(engine):
    BaseModel.metadata.drop_all(engine)



if __name__ == '__main__':
    import sys
    sys.path.insert(0, '../..')
    from sqlalchemy import create_engine
    from sqlalchemy.orm import sessionmaker
    Engine = create_engine('mysql://root@localhost:3306/core1', echo=True)
    #Session = sessionmaker(Engine)
    #session = Session()
    #b = session.query(Block).all()
    init_db(Engine)
    #drop_db(Engine)



